package com.mastercard.labs

import grails.converters.JSON

import java.text.SimpleDateFormat

class DashboardController {

	def cardService, transactionService

	def index() {
	}

	def dashboard() {

		// Get cards
		def user = User.findByEmail("david@gmail.com")
		def cards = cardService.getCards(user)

		// Get transactions
		Calendar cal = Calendar.getInstance()
		cal.set(2012, 1, 1);
		Date fromDate = cal.getTime()
		def transactions = transactionService.getTransactions(fromDate, new Date())
		render (view: 'dashboard', model:[cardsJSON:new JSON(cards).toString(),
					transactions: transactions,
					dateFormat: new SimpleDateFormat("dd-MMM-yyyy")])
	}

	def profile() {
	}

	def report() {
	}
}
